weiXinController.controller('operationMsgCtl',['$scope','$state','$stateParams','$timeout','$interval','$compile','$rootScope','$filter',function($scope,$state,$stateParams,$timeout,$interval,$compile,$rootScope,$filter) {
	
	/**
	 * 查询初始化
	 */
	var postData = {};
	var param = {
		id : 'tableDemo',
		checkbox : false,
		column : [
			{
				type:'rowNum',
				title:'编号',
				titleTdStyle: 'width: 100px;color: #17a2b8;'
			},{
				type:'key',
				mapping:'id',
				show:false
			},{
				mapping: '?',
            	title:'时间',
            	trans:function(data){
            		return data.gmt_modified;
            	}
			},{
				mapping: '?',
            	title:'标题',
            	trans:function(data){
            		return data.title;
            	}
			},{
				mapping:'?',
                title:'正文',
                trans:function(data){
                	return data.content;
                }
			}
		],
		pageConfig:{
			showGoNum:false
		},
		page:function(cmd, currentPage, pageSize, totalPageNum){
            if('first' === cmd){
                currentPage = 1;
            }else if('prev' === cmd){
                currentPage--;
            }else if('next' === cmd){
                currentPage++;
            }else if('last' === cmd){
                currentPage = totalPageNum;
            }else if('change' === cmd){
                currentPage = 1;
            }
            $scope.search(currentPage,pageSize);
        }
	};
	EdeyeAdmin.initDataTablePhone(param, {data:[]});
	
	/**
	 * 搜索
	 */
	$scope.search = function(currentPage, pageSize){
		postData.currentPage = (currentPage === undefined ? 1 : currentPage);
		postData.pageSize = (pageSize === undefined ? EdeyeAdmin.getPageSizePhone(param.id) : pageSize);
		EdeyeAdmin.post({
			url:'/operationMsg/page',
			data:postData
		},{
			SUCCESS:function(ret){
				if(ret.code === '200'){
					EdeyeAdmin.setDataTableDataPhone(param, ret.data);
				}
			}
		});
	}
	
	$scope.search();
	
	/**
	 * 测试消息通知
	 */
	$scope.testOperation = function(){
		var postData = {};
		postData.roleId = 4;
		postData.title = "测试";
		postData.content = "测试消息通知";
		postData.range = "SOCKET";  // ALL , WX , SOCKET
		postData.data = "不知道干嘛用的"
		EdeyeAdmin.post({
			url:'/log/testOperation',
			data:postData
		},{
			SUCCESS:function(ret){
				console.log(ret);
			}
		});
	}
}]);